<?php

declare(strict_types=1);

namespace App\Controller\Admin;

use App\Constants\ErrorCode;
use App\Controller\AbstractController;
use App\Service\AdminLogService;
use Hyperf\Di\Annotation\Inject;
use App\Utils\ApiUtils;

class LogController extends AbstractController
{

    /**
     * @Inject
     * @var AdminLogService
     */
    protected $adminLogService;

    /**
     * 获取管理员日志列表
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function list()
    {
        $page = $this->request->input('page', 1);
        $pageSize = $this->request->input('pageSize', 15);
        $name = $this->request->input('name', '');
        $startDate = $this->request->input('start_date');
        $endDate = $this->request->input('end_date');
        $result = $this->adminLogService->list($page, $pageSize, $name, $startDate, $endDate);
        return $this->response->json(ApiUtils::send(ErrorCode::SUCCESS,'获取成功', $result['list'], $result['count']));
    }


}
